package cn.com.huzo.webapp.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * 错误控制器
 * <p>
 * @author 吴旭
 */
@Controller
public class ErrorController {

    /**
     * 跳转到一般错误画面
     * <p>
     * @return
     */
    @RequestMapping("error.html")
    public ModelAndView redirectError() {
        ModelAndView view = new ModelAndView();
        view.setViewName("errors/GenericErrorPage");
        return view;
    }

    /**
     * 跳转到500错误画面
     * <p>
     * @return
     */
    @RequestMapping("500.html")
    public ModelAndView redirect500() {
        ModelAndView view = new ModelAndView();
        view.setViewName("errors/GenericErrorPage");
        return view;
    }

    /**
     * 跳转到500错误画面
     * <p>
     * @return
     */
    @RequestMapping("400.html")
    public ModelAndView redirect400() {
        ModelAndView view = new ModelAndView();
        view.setViewName("errors/BadRequest");
        return view;
    }

    /**
     * 跳转到403错误画面
     * <p>
     * @return
     */
    @RequestMapping("403.html")
    public ModelAndView redirect403() {
        ModelAndView view = new ModelAndView();
        view.setViewName("errors/NoAccess");
        return view;
    }

    /**
     * 跳转到404错误画面
     * <p>
     * @return
     */
    @RequestMapping("404.html")
    public ModelAndView redirect404() {
        ModelAndView view = new ModelAndView();
        view.setViewName("errors/FileNotFound");
        return view;
    }
}
